﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using XSTDZ.ERP.Application.DataContracts;
using XSTDZ.ERP.Core.Extentions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;  

namespace XSTDZ.ERP.WebApp.Models
{
    /// <summary>
    /// 出库单
    /// </summary>
    public class ProductOutBillModel
    {
        public bool ValidateCode(string validateCode)
        {
            return true;
        }
        //根据指定的页面字段名称，获得相应的GUID值
        public Guid GetRequestFormValues(HttpContextBase context,string fileName)
        {
            if (!string.IsNullOrEmpty(fileName))
            {
                if (context.Request.Form[fileName] != null)
                {
                    Guid wareHourseId;
                    if (Guid.TryParse(context.Request.Form[fileName].ToString(), out wareHourseId))
                    {
                        return wareHourseId;
                    }
                }
            }
            return Guid.Empty;
        }

        public IList<ProductOutBillDetailDto> GetProductItems(string jsons)
        {
            if (string.IsNullOrEmpty(jsons))
            {
                return null;
            }
            try
            {
                return JsonConvert.DeserializeObject<List<ProductOutBillDetailDto>>(jsons);  
            }
            catch (Exception)
            {
                return null;
            }
           
        }
        
       
    }

    #region 打印类
    public class ProductOutPrint
    {
        public ProductOutBillDto ProductOutBillDto { get; set; }
        public IEnumerable<ProductOutBillDetailDto> ProductOutBillDetailsDto { get; set; }
    }
    #endregion
    #region 收货确认打印类
    public class ProductDeliveryBillPrint
    {
        public ProductDeliveryBillDto ProductDeliveryBillDto { get; set; }
        public IEnumerable<ProductDeliveryBillDetailDto> ProductDeliveryBillDetailDtos { get; set; }
    }
    #endregion

}